<template>
  <Promised :promise="getUserAsync">
    <template v-slot:pending>
      <Skeleton />
    </template>
    <template v-slot="user">
      <section>
        <a-card :bordered="false">
          <AccountForm :user="user" />

          <a-divider />

          <BasicForm :user="user" />

          <a-divider />

          <BlankForm :user="user" />
        </a-card>
      </section>
    </template>
  </Promised>
</template>

<script>
import { getRegisterUserInfo } from '@/api/flow/user'
import AccountForm from './Account.vue'
import BasicForm from './Basic.vue'
import BlankForm from './Blank'

export default {
  data () {
    return {
      getUserAsync: null,
    }
  },

  components: {
    AccountForm,
    BasicForm,
    BlankForm,
  },

  created () {
    this.getUserAsync = this.getUser()
  },

  computed: {
    uid () {
      return this.$route.params.uid
    },
  },

  methods: {
    getUser () {
      return new Promise((resolve, reject) => {
        getRegisterUserInfo(this.uid)
          .then(data => {
            resolve(data)
          })
          .catch(error => {
            reject(error)
          })
      })
    },
  },
}

</script>

<style lang="scss" scoped>
.actions-container {
  margin-bottom: $margin-md;
}
</style>
